#pragma once
#include <vector>
#include <queue>

#include "Frame.hxx"
class PipeLine;

class StreamSynchronizer
{
public:
	StreamSynchronizer(PipeLine* pipeLine);
	~StreamSynchronizer(void);

	void synchronizeFrame( int channelIndex, Frame* frame );

	void start();
	void stop();

	void initialize();

	inline bool isStopped() { return _isStopped; }

	void execute();

	inline PipeLine* getPipeLine() { return _pipeLine; }

	
	void lock();
	void unlock();
private:
	PipeLine* _pipeLine;
	bool _isStopped;

	std::queue<SyncFrame*> _unSyncArray[ 3 ];
	std::queue<SyncFrame*> _syncedFrames;
	int _nextSyncedIndex; 
	
	CRITICAL_SECTION _syncCs; 
};

